Skip to content

feat(appkit): add agent plugin core and ToolProvider implementations#284

Draft
MarioCadenas wants to merge 1 commit intoagent/2a-tool-types-mcpfrom
agent/2b-plugin-core
Draft

feat(appkit): add agent plugin core and ToolProvider implementations#284
MarioCadenas wants to merge 1 commit intoagent/2a-tool-types-mcpfrom
agent/2b-plugin-core

Conversation

@MarioCadenas
Copy link
Copy Markdown
Collaborator

@MarioCadenas MarioCadenas commented Apr 16, 2026

Summary

PR 3 of 5 (2b) in the agent plugin stack.

  • AgentPlugin class: HTTP routes (/chat, /cancel, /threads, /invocations), tool collection from ToolProvider plugins + FunctionTool + MCP, SSE streaming via executeStream, thread management
  • AgentEventTranslator: stateful converter from internal AgentEvent to OpenAI Responses API ResponseStreamEvent with sequence numbers and output indices
  • InMemoryThreadStore: per-user conversation persistence with nested Map
  • Zod request schemas for /chat and /invocations endpoints
  • ToolProvider implementations added to analytics, files, genie, and lakebase plugins
  • Server plugin addExtension() method for internal plugin-to-plugin route registration

PR Stack

  1. Shared types + Adapters — feat(appkit): add shared agent types and LLM adapter implementations #282
  2. Tool types + MCP client — feat(appkit): add FunctionTool, HostedTool types and MCP client #283
  3. Agent plugin core + ToolProvider implementations (this PR)
  4. PluginContext mediator — feat(appkit): add PluginContext mediator for inter-plugin communication #285
  5. createAgent + apps + docs — feat(appkit): add createAgent wrapper, agent-app, and API docs #286

Test plan

  • 1642 tests pass
  • Typecheck clean
  • Biome lint clean

Add the agent plugin with all supporting infrastructure:

- AgentPlugin class: routes, tool collection, SSE streaming, thread mgmt
- AgentEventTranslator: converts AgentEvent to OpenAI Responses API format
- InMemoryThreadStore: per-user conversation persistence
- Config-driven agents: frontmatter markdown files in config/agents/
- Layered system prompts: auto-generated base (guidelines + app context)
  prepended to per-agent user prompt
- AgentDefinition union type: agents accept { adapter, systemPrompt }
- Auto-discovery: config files merged with code-defined agents per-name
- reloadAgents() export for future hot-reload support
- ToolProvider implementations for analytics, files, genie, lakebase
- Server plugin addExtension() for plugin-to-plugin route registration

Also add a shared defineTool() helper for ToolProvider plugins and refactor
the four built-in ToolProviders to use it:

- defineTool(): Zod-powered factory that pairs a schema with a typed handler
  and optional ToolAnnotations. Names are supplied by the enclosing registry
  key, so dotted names like `uploads.list` or `myspace.sendMessage` work
  without any special-case dispatch code.
- executeFromRegistry(): generic dispatcher that looks up an entry by name,
  validates args via safeParse, and returns an LLM-friendly error string on
  failure rather than throwing.
- toolsFromRegistry(): derives the AgentToolDefinition[] from a registry,
  generating JSON Schema from each entry's Zod schema.
- analytics, files, genie, lakebase: getAgentTools() / executeAgentTool()
  now delegate to the shared helpers. Static plugins (analytics, lakebase)
  declare the registry as a class field; dynamic plugins (files, genie)
  build per-volume / per-space entries in the constructor after runtime
  config is known.

Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
@MarioCadenas MarioCadenas force-pushed the agent/2b-plugin-core branch from f0362ab to 0726869 Compare April 17, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant